1include <gridfinity-rebuilt-utility.scad>
  2
  3// ===== INFORMATION ===== //
  4/*
  5 IMPORTANT: rendering will be better for analyzing the model if fast-csg is enabled. As of writing, this feature is only available in the development builds and not the official release of OpenSCAD, but it makes rendering only take a couple seconds, even for comically large bins. Enable it in Edit > Preferences > Features > fast-csg
  6 the magnet holes can have an extra cut in them to make it easier to print without supports
  7 tabs will automatically be disabled when gridz is less than 3, as the tabs take up too much space
  8 base functions can be found in "gridfinity-rebuilt-utility.scad"
  9 examples at end of file
 10
 11 BIN HEIGHT
 12 the original gridfinity bins had the overall height defined by 7mm increments
 13 a bin would be 7*u millimeters tall
 14 the lip at the top of the bin (3.8mm) added onto this height
 15 The stock bins have unit heights of 2, 3, and 6:
 16 Z unit 2 -> 7*2 + 3.8 -> 17.8mm
 17 Z unit 3 -> 7*3 + 3.8 -> 24.8mm
 18 Z unit 6 -> 7*6 + 3.8 -> 45.8mm
 19
 20https://github.com/kennetek/gridfinity-rebuilt-openscad
 21
 22*/
 23
 24// ===== PARAMETERS ===== //
 25
 26/* [Setup Parameters] */
 27$fa = 8;
 28$fs = 0.25;
 29
 30/* [General Settings] */
 31// number of bases along x-axis
 32gridx = 3;
 33// number of bases along y-axis
 34gridy = 2;
 35// bin height. See bin height information and "gridz_define" below.
 36gridz = 6;
 37
 38/* [Linear Compartments] */
 39// number of X Divisions (set to zero to have solid bin)
 40divx = 0;
 41// number of Y Divisions (set to zero to have solid bin)
 42divy = 0;
 43
 44/* [Cylindrical Compartments] */
 45// number of cylindrical X Divisions (mutually exclusive to Linear Compartments)
 46cdivx = 0;
 47// number of cylindrical Y Divisions (mutually exclusive to Linear Compartments)
 48cdivy = 0;
 49// orientation
 50c_orientation = 2; // [0: x direction, 1: y direction, 2: z direction]
 51// diameter of cylindrical cut outs
 52cd = 10;
 53// cylinder height
 54ch = 1;
 55// spacing to lid
 56c_depth = 1;
 57// chamfer around the top rim of the holes
 58c_chamfer = 0.5;
 59
 60/* [Height] */
 61// determine what the variable "gridz" applies to based on your use case
 62gridz_define = 0; // [0:gridz is the height of bins in units of 7mm increments - Zack's method,1:gridz is the internal height in millimeters, 2:gridz is the overall external height of the bin in millimeters]
 63// overrides internal block height of bin (for solid containers). Leave zero for default height. Units: mm
 64height_internal = 0;
 65// snap gridz height to nearest 7mm increment
 66enable_zsnap = false;
 67
 68/* [Features] */
 69// the type of tabs
 70style_tab = 1; //[0:Full,1:Auto,2:Left,3:Center,4:Right,5:None]
 71// how should the top lip act
 72style_lip = 0; //[0: Regular lip, 1:remove lip subtractively, 2: remove lip and retain height]
 73// scoop weight percentage. 0 disables scoop, 1 is regular scoop. Any real number will scale the scoop.
 74scoop = 1; //[0:0.1:1]
 75// only cut magnet/screw holes at the corners of the bin to save uneccesary print time
 76only_corners = false;
 77
 78/* [Base] */
 79style_hole = 4; // [0:no holes, 1:magnet holes only, 2: magnet and screw holes - no printable slit, 3: magnet and screw holes - printable slit, 4: Gridfinity Refined hole - no glue needed]
 80// number of divisions per 1 unit of base along the X axis. (default 1, only use integers. 0 means automatically guess the right division)
 81div_base_x = 0;
 82// number of divisions per 1 unit of base along the Y axis. (default 1, only use integers. 0 means automatically guess the right division)
 83div_base_y = 0;
 84
 85
 86
 87// ===== IMPLEMENTATION ===== //
 88
 89color("tomato") {
 90gridfinityInit(gridx, gridy, height(gridz, gridz_define, style_lip, enable_zsnap), height_internal, sl=style_lip) {
 91
 92    if (divx > 0 && divy > 0) {
 93
 94        cutEqual(n_divx = divx, n_divy = divy, style_tab = style_tab, scoop_weight = scoop);
 95
 96    } else if (cdivx > 0 && cdivy > 0) {
 97
 98        cutCylinders(n_divx=cdivx, n_divy=cdivy, cylinder_diameter=cd, cylinder_height=ch, coutout_depth=c_depth, orientation=c_orientation, chamfer=c_chamfer);
 99    }
100}
101gridfinityBase(gridx, gridy, l_grid, div_base_x, div_base_y, style_hole, only_corners=only_corners);
102}
103
104
105// ===== EXAMPLES ===== //
106
107// 3x3 even spaced grid
108/*
109gridfinityInit(3, 3, height(6), 0, 42) {
110	cutEqual(n_divx = 3, n_divy = 3, style_tab = 0, scoop_weight = 0);
111}
112gridfinityBase(3, 3, 42, 0, 0, 1);
113*/
114
115// Compartments can be placed anywhere (this includes non-integer positions like 1/2 or 1/3). The grid is defined as (0,0) being the bottom left corner of the bin, with each unit being 1 base long. Each cut() module is a compartment, with the first four values defining the area that should be made into a compartment (X coord, Y coord, width, and height). These values should all be positive. t is the tab style of the compartment (0:full, 1:auto, 2:left, 3:center, 4:right, 5:none). s is a toggle for the bottom scoop.
116/*
117gridfinityInit(3, 3, height(6), 0, 42) {
118    cut(x=0, y=0, w=1.5, h=0.5, t=5, s=0);
119    cut(0, 0.5, 1.5, 0.5, 5, 0);
120    cut(0, 1, 1.5, 0.5, 5, 0);
121
122    cut(0,1.5,0.5,1.5,5,0);
123    cut(0.5,1.5,0.5,1.5,5,0);
124    cut(1,1.5,0.5,1.5,5,0);
125
126    cut(1.5, 0, 1.5, 5/3, 2);
127    cut(1.5, 5/3, 1.5, 4/3, 4);
128}
129gridfinityBase(3, 3, 42, 0, 0, 1);
130*/
131
132// Compartments can overlap! This allows for weirdly shaped compartments, such as this "2" bin.
133/*
134gridfinityInit(3, 3, height(6), 0, 42)  {
135    cut(0,2,2,1,5,0);
136    cut(1,0,1,3,5);
137    cut(1,0,2,1,5);
138    cut(0,0,1,2);
139    cut(2,1,1,2);
140}
141gridfinityBase(3, 3, 42, 0, 0, 1);
142*/
143
144// Areas without a compartment are solid material, where you can put your own cutout shapes. using the cut_move() function, you can select an area, and any child shapes will be moved from the origin to the center of that area, and subtracted from the block. For example, a pattern of three cylinderical holes.
145/*
146gridfinityInit(3, 3, height(6), 0, 42) {
147    cut(x=0, y=0, w=2, h=3);
148    cut(x=0, y=0, w=3, h=1, t=5);
149    cut_move(x=2, y=1, w=1, h=2)
150        pattern_linear(x=1, y=3, sx=42/2)
151            cylinder(r=5, h=1000, center=true);
152}
153gridfinityBase(3, 3, 42, 0, 0, 1);
154*/
155
156// You can use loops as well as the bin dimensions to make different parametric functions, such as this one, which divides the box into columns, with a small 1x1 top compartment and a long vertical compartment below
157/*
158gx = 3;
159gy = 3;
160gridfinityInit(gx, gy, height(6), 0, 42) {
161    for(i=[0:gx-1]) {
162        cut(i,0,1,gx-1);
163        cut(i,gx-1,1,1);
164    }
165}
166gridfinityBase(gx, gy, 42, 0, 0, 1);
167*/
168
169// Pyramid scheme bin
170/*
171gx = 4.5;
172gy = 4;
173gridfinityInit(gx, gy, height(6), 0, 42) {
174    for (i = [0:gx-1])
175    for (j = [0:i])
176    cut(j*gx/(i+1),gy-i-1,gx/(i+1),1,0);
177}
178gridfinityBase(gx, gy, 42, 0, 0, 1);
179*/